package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.beans.annotation.LoginAdminShopId;
import org.linlinjava.litemall.admin.service.AdminLumiereFormulaMaterialService;
import org.linlinjava.litemall.admin.vo.formulamaterial.FormulaMaterialMultipleRespVO;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LumiereFormulaMaterial;
import org.springframework.web.bind.annotation.*;

@Api(tags = "配方原料管理API")
@RestController
@RequestMapping("admin/formulaMaterial")
@RequiredArgsConstructor
public class AdminLumiereFormulaMaterialController {

    private final AdminLumiereFormulaMaterialService adminLumiereFormulaMaterialService;

    @ApiOperation("配方原料管理-查询配方原料列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit",value = "数量"),
            @ApiImplicitParam(name = "page",value = "当前页"),
            @ApiImplicitParam(name = "formulaId",value = "配方id")
    })
    @LogAnno
    @GetMapping("/list")
    public ResponseUtil.Response list(LumiereFormulaMaterial lumiereFormulaMaterial,
                                      @RequestParam("page")Integer page,
                                      @RequestParam("limit")Integer limit) {
        return adminLumiereFormulaMaterialService.listLumiereFormulaMaterial(lumiereFormulaMaterial,page,limit);
    }

    @ApiOperation("配方原料管理-查询配方原料列表")
    @LogAnno
    @GetMapping("/list-all")
    public ResponseUtil.Response listAll() {
        return adminLumiereFormulaMaterialService.listAllLumiereFormulaMaterial();
    }


    @ApiOperation("配方原料管理-查询配方原料列表")
    @LogAnno
    @PostMapping("/multiple")
    public ResponseUtil.Response multiple(@RequestBody FormulaMaterialMultipleRespVO materialMultipleRespVO) {
        return adminLumiereFormulaMaterialService.listMultipleLumiereFormulaMaterial(materialMultipleRespVO);
    }


    @ApiOperation("配方原料管理-新增配方原料")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "formulaName",value = "配方名称"),
    })
    @LogAnno
    @PostMapping("/add")
    public ResponseUtil.Response add(LumiereFormulaMaterial lumiereFormulaMaterial)  {
        return adminLumiereFormulaMaterialService.addLumiereFormulaMaterial(lumiereFormulaMaterial);
    }

    @ApiOperation("配方原料管理-编辑配方原料")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "formulaName",value = "配方名称"),
    })
    @LogAnno
    @PutMapping ("/update")
    public ResponseUtil.Response update(LumiereFormulaMaterial lumiereFormulaMaterial)  {
        return adminLumiereFormulaMaterialService.updateLumiereFormulaMaterial(lumiereFormulaMaterial);
    }

    @ApiOperation("配方原料管理-删除配方原料")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id"),
    })
    @LogAnno
    @DeleteMapping("/delete")
    public ResponseUtil.Response delete(Integer id)  {
        return adminLumiereFormulaMaterialService.deleteLumiereFormulaMaterial(id);
    }



}
